package org.system.core.controller.system;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.system.core.annotation.Log;
import org.system.core.common.Result;
import org.system.core.domain.entity.SysConfig;
import org.system.core.enums.BusinessType;
import org.system.core.service.system.SysConfigService;

@RestController
@Api(tags = {"系统配置模块"})
@RequestMapping("/system/config")
public class SysConfigController {

    private static final Logger logger = LoggerFactory.getLogger(SysConfigController.class);

    @Autowired
    private SysConfigService sysConfigService;

    @PutMapping
    @ApiOperation("更新用户配置")
    @Log(title = "配置管理", businessType = BusinessType.UPDATE)
    public Result<String> updateConfig(@RequestBody SysConfig sysConfig) {
        logger.info("更新用户配置信息, {}", sysConfig);
        sysConfigService.updateConfig(sysConfig);
        return Result.ok();
    }

//    @PostMapping
//    @ApiOperation("新增用户配置")
//    @Log(title = "配置管理", businessType = BusinessType.INSERT)
//    public Result<String> addConfig(@RequestBody SysConfig sysConfig) {
//        logger.info("新增用户配置：{}", sysConfig);
//        // todo 由于用户可能没有权限的原因，所以不是所有的用户都有配置，当用户登录之后保存配置才有单独的配置
//        sysConfigService.insertConfig(sysConfig);
//        return Result.ok();
//    }


}
